from typing import List, Literal, Optional, Union
from peewee import Check
from pydantic import BaseModel

class ChapterModel(BaseModel):
    id:int
    title:str
    is_xueshuo:bool
    is_zhuanshuo:bool
    question_count:int

    class Config:
        orm_mode = True

class OptionModel(BaseModel):
    key:str
    value:str

    class Config:
        orm_mode = True

class SheetItemModel(BaseModel):
    question_id:int
    order:int
    qtype:str
    check_count:int
    right_count:int
    checked:bool
    accuracy:float
    last_check_right:bool

    class Config:
        orm_mode = True

class QuestionModel(BaseModel):
    id:int
    title:str
    number:str
    year:int
    restore:str
    explain:str
    question_type:int
    answer:str
    subject_name:str
    xueshuo_dagang:str
    zhuanshuo_dagang:str
    is_xueshuo:bool
    is_zhuanshuo:bool
    is_hot:bool
    chapter_id:int
    source:Optional[str]
    options:List[OptionModel]
    answer_sheet:SheetItemModel

    class Config:
        orm_mode = True

class ProgressType:
    Subject='subject'
    Chapter='chapter'
    Year='year'


class ProgressModel(BaseModel):
    title:str
    key:int
    # type:Union[Literal['subject'],Literal['chapter'],Literal['subject']]
    total_count:int=0
    wrong_percent:float=0
    right_percent:float=0
    undo_percent:float=1.0

class YearProgressModel(ProgressModel):
    type=ProgressType.Year


class SubjectProgressModel(ProgressModel):
    type=ProgressType.Subject

class ChapterProgressModel(ProgressModel):
    type=ProgressType.Chapter